﻿@model Coslen.TahorCRM.Domain.Entities.ViewModels.Searching.ContactSearchViewModel


<h4>Please select a contact...</h4>

<script language="javascript" type="text/javascript">
    $(function () {
        $('#SearchButton').click(function () {
            
            var firstName = $("#FirstName").val();
            var lastName = $("#LastName").val();
            var parameters = "firstName=" + firstName + "&lastName=" + lastName;

            //alert("Reload the search form... Parameters = [" + parameters + "]");
            $.ajax({
                type: 'get',
                dataType: 'html',
                url: '@Url.Action("GetContactSelectorSearchResult","Contact")',
                async: false,
                data: parameters,
                success: successFn,
                error: errorFn
            });


            return false;
        });
    });
    


    function successFn(response) {
//        alert(response);
        $("#searchResults").html(response);
    }

    function errorFn(xhr, ajaxOptions, thrownError) {
        alert(xhr.statusText + "<br/>" + thrownError);
    }

</script>

<div id="searchForm">
    
<fieldset>
    <div class="filterHeader">Search</div>
    <div class="filter">
        <fieldset>
            <div class="editor-row">
                <div class="editor-label">
                    @Html.LabelFor(model => model.FirstName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.FirstName)
                </div>
            </div>
            <div class="editor-row">
                <div class="editor-label">
                    @Html.LabelFor(model => model.LastName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.LastName)
                </div>
            </div>
            <div class="editor-row">
                <div class="editor-label">
                </div>
                <div class="editor-field">
                    <input id="SearchButton" name="SearchButton" type="submit" value="Search" />
                </div>
            </div>
        </fieldset>
    </div>
</fieldset>
</div>

<div id="searchResults">
    
</div>